package com.punai.customer.mapper;

import com.punai.common.core.mapper.CommonMapper;
import com.punai.customer.domain.CusMaterialItem;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 材料费用项Mapper接口
 *
 * @author zxw
 * @date 2022-12-04
 */
public interface CusMaterialItemMapper extends CommonMapper<CusMaterialItem>
{
    /**
     * 查询材料费用项
     *
     * @param id 材料费用项主键
     * @return 材料费用项
     */
    public CusMaterialItem selectCusMaterialItemById(@Param("id")String id,@Param("companyId")Long companyId);

    /**
     * 查询材料费用项列表
     *
     * @param cusMaterialItem 材料费用项
     * @return 材料费用项集合
     */
    public List<CusMaterialItem> selectCusMaterialItemList(CusMaterialItem cusMaterialItem);


    /**
     * 删除材料费用项
     *
     * @param id 材料费用项主键
     * @return 结果
     */
    public int deleteCusMaterialItemById(String id);

    /**
     * 批量删除材料费用项
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteCusMaterialItemByIds(@Param("ids")List<String>  ids,@Param("companyId")Long companyId);

    /**
     * 删除章节时费用项id设0
     *
     * 2023-02-27 废弃 原因：章节递归删除
     *
     * @param id 需要修改的数据章节id
     * @return 结果
     */
    public int setChapterIdIsZero(@Param("id")String id,@Param("companyId")Long companyId);

    void updateChapterIdByIds(@Param("ids") String[] ids, @Param("chapterId") String chapterId,@Param("companyId")Long companyId);

    List<CusMaterialItem> selectLinkFlagData(@Param("linkFlag") String linkFlag,@Param("chapterId")String chapterId,
                                             @Param("companyId") Long companyId,@Param("itemName") String itemName);

    Integer selectLinkFlagCount(@Param("linkFlag") String linkFlag,@Param("chapterIds")List<String> chapterIds,
                                             @Param("companyId") Long companyId);

    Integer countByChapterId(@Param("companyId") Long companyId);

    void rewriteMaterialCode(@Param("companyId") Long companyId,@Param("prefix") String prefix,@Param("suffixLen") Integer suffixLen);

    Integer getMaxOrderNumByChapterId(@Param("chapterId") String chapterId, @Param("companyId")Long companyId);

    List<String>  selectIdsByChapterIds(@Param("companyId")Long companyId,@Param("chapterIds") List<String> chapterIds);

    public List<CusMaterialItem> queryContrast(@Param("companyId")Long companyId,@Param("ids") String[] ids);

    int updateChapterIdIsZero(@Param("chapterIds") List<String> chapterIds,@Param("companyId") Long companyId,@Param("chapterId") String chapterId);

    int countNotAllot(@Param("companyId") Long companyId,@Param("notClassifiedId") String notClassifiedId);
}
